

Const ForReading=1
Const ForWriting=2

Set WshShell = WScript.CreateObject("WScript.Shell")
strSystemRoot = WshShell.ExpandEnvironmentStrings("%SystemRoot%")

 scriptini = strSystemRoot & "\system32\GroupPolicy\gpt.ini"

Set objFSO = CreateObject("Scripting.FileSystemObject")
'folder = "C:\Program Files\Vendor\"
'filePath = folder & "file.txt"
Set myFile = objFSO.OpenTextFile(scriptini, ForReading, True)
Set myTemp= objFSO.OpenTextFile(scriptini & ".tmp", ForWriting, True)
Do While Not myFile.AtEndofStream
 myLine = myFile.ReadLine
 If InStr(myLine, "gPCUserExtensionNames=") Then
  myLine = "gPCUserExtensionNames="& "[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B66650-4972-11D1-A7CA-0000F87571E3}]"
 End If
'myLine= "[Logoff]" & "0CmdLine=logoff.vbs" & "0Parameters="
 myTemp.WriteLine myLine
Loop
myFile.Close
myTemp.Close
objFSO.DeleteFile(scriptini)
objFSO.MoveFile scriptini&".tmp", scriptini



'this code for write scripts.ini file 
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText

Set WshShell = WScript.CreateObject("WScript.Shell")
strSystemRoot = WshShell.ExpandEnvironmentStrings("%SystemRoot%")

 strDirectory = strSystemRoot & "\system32\GroupPolicy\User\Scripts"
 
 
 strFile = "\scripts.ini"
 
strText = "[Logoff]" & Chr(13) & Chr(10) & "0CmdLine=logoff.vbs" & Chr(13) & Chr(10) & "0Parameters="

' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
   Set objFolder = objFSO.GetFolder(strDirectory)
Else
   Set objFolder = objFSO.CreateFolder(strDirectory)
   WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
   Set objFolder = objFSO.GetFolder(strDirectory)
Else
   Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
   Wscript.Echo "Just created " & strDirectory & strFile
End If 

set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)

' Writes strText every time you run this VBScript
objTextFile.WriteLine(strText)
objTextFile.Close

' Bonus or cosmetic section to launch explorer to check file
If err.number = vbEmpty then
   Set objShell = CreateObject("WScript.Shell")
   objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If

'create logoff.vbs files in logoff directory



Set WshShell = WScript.CreateObject("WScript.Shell")
strSystemRoot = WshShell.ExpandEnvironmentStrings("%SystemRoot%")

 strDirectory = strSystemRoot & "\system32\GroupPolicy\User\Scripts\Logoff"
 
 
 strFile = "\logoff.vbs"
 'Wscript.Echo "" & URL
strText = "machineID=1" & Chr(13) & Chr(10) & "URL =" & chr(34)& "http://localhost:8080/rssrest/res/helloworld/killprocess" & chr(34) & Chr(13) & Chr(10) & "Set http = CreateObject(" & chr(34)& "MSXML2.XmlHttp" & chr(34) & ")" & Chr(13) & Chr(10) & "http.open " & chr(34)& "GET" & chr(34) & ", URL , FALSE" & Chr(13) & Chr(10) & "http.setRequestHeader " & chr(34) & "Content-Type" & chr(34) & "," & chr(34)& "'application/soap+xml; charset=utf-8" & chr(34) & Chr(13) & Chr(10) & "http.setRequestHeader" & "" & chr(34) & "Content-Length" & chr(34)& "," & chr(34)& "255" & chr(34) & Chr(13) & Chr(10) & "http.send" & "" &  chr(34) & "null"& chr(34)
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
   Set objFolder = objFSO.GetFolder(strDirectory)
Else
   Set objFolder = objFSO.CreateFolder(strDirectory)
   WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
   Set objFolder = objFSO.GetFolder(strDirectory)
Else
   Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
   Wscript.Echo "Just created " & strDirectory & strFile
End If 

set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, 
'Const ForWriting = 2

Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForWriting, True)

' Writes strText every time you run this VBScript
objTextFile.WriteLine(strText)
objTextFile.Close

' Bonus or cosmetic section to launch explorer to check file
If err.number = vbEmpty then
   Set objShell = CreateObject("WScript.Shell")
   objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If

'WScript.Quit
'VBScript Registry File created with Reg2VBS v1.5
'v1.0 Coded by Tim Mortimer
'v1.5 Coded by Denis St-Pierre (ottawa, Canada)
'Creation time: 4/8/2012 2:42:24 PM
'Option Explicit
'Dim objShell
'Set objShell = CreateObject("WScript.Shell")

'Add StdRegProv support in case of Binary, Multi_SZ values
Dim strComputer, ArrOfValue, oReg
const HKEY_USERS = &H80000003
const HKEY_LOCAL_MACHINE = &H80000002
const HKEY_CURRENT_USER = &H80000001
const HKEY_CLASSES_ROOT = &H80000000
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")	'used for Binary, Multi_SZ values
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\", ""
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\", ""
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\", ""
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\GPO-ID", "LocalGPO", "REG_SZ"
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\SOM-ID", "Local", "REG_SZ"
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\FileSysPath", "%SystemRoot%\\System32\\GroupPolicy\\User", "REG_SZ"
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\DisplayName", "Local Group Policy", "REG_SZ"
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\GPOName", "Local Group Policy", "REG_SZ"
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0\", ""
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0\Script", "logoff.vbs", "REG_SZ"
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0\Parameters", "", "REG_SZ"
'Unknown value type"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
objShell.RegWrite "HKCU\Software\Policies\Microsoft\Windows\System\Scripts\Logon\", ""
Set objShell = Nothing
'WScript.Quit




'VBScript Registry File created with Reg2VBS v1.5
'v1.0 Coded by Tim Mortimer
'v1.5 Coded by Denis St-Pierre (ottawa, Canada)
'Creation time: 4/8/2012 5:06:14 PM
'Option Explicit
'Dim objShell
Set objShell = CreateObject("WScript.Shell")

'Add StdRegProv support in case of Binary, Multi_SZ values
'Dim  ArrOfValue, oReg
'const HKEY_USERS = &H80000003
'const HKEY_LOCAL_MACHINE = &H80000002
'const HKEY_CURRENT_USER = &H80000001
'const HKEY_CLASSES_ROOT = &H80000000
'strComputer = "."
'Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")	'used for Binary, Multi_SZ values
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\", ""
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\Options", 0, "REG_DWORD"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\Version", 1048592, "REG_DWORD"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\DSPath", "LocalGPO", "REG_SZ"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\FileSysPath", "C:\\WINDOWS\\System32\\GroupPolicy\\User", "REG_SZ"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\DisplayName", "Local Group Policy", "REG_SZ"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\Extensions", "[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B66650-4972-11D1-A7CA-0000F87571E3}]", "REG_SZ"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\Link", "Local", "REG_SZ"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\GPOName", "Local Group Policy", "REG_SZ"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\GPOLink", 1, "REG_DWORD"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy\History\{42B5FAAE-6536-11d2-AE5A-0000F87571E3}\0\lParam", 0, "REG_DWORD"
Set objShell = Nothing
WScript.Quit
